<?php
namespace Modules\Activity\Entities\Fudai;;

use Modules\Core\Entities\BaseEntity as Model;
use ThrowException;

use Modules\Order\Traits\Skuable;

// 一番赏活动 副表
class Sku extends Model
{
    use Skuable;
    
    protected $table = 'fudai_skus';

   	protected $guarded = ['total_odds'];
    static public $resourcename = '福袋奖品';

    public $total_odds = 0;

    protected $casts = [
        'assets' => 'json',
        'detail_images' => 'json'
    ];

    public function activity()
    {
        return $this->belongsTo('\Modules\Activity\Entities\Fudai\Activity', 'activity_id');
    }

    public function scopeLevel($qeury, $level)
    {
    	return $qeury->where('level', $level);
    }

    // 获取列表
    static public function beforeGetList($options) 
    {
    	if (@$options['level']) {
    		$options['scopes']['level'] = $options['level'];
    	}

    	return $options;
    }
}
